# /usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2022/1/15 23:33
# @Author  : lt
# @Email   : lt@163.com
# @File    : page_shoppingcar.py
# @Software: PyCharm
from appium.webdriver.common.touch_action import TouchAction

from pages.page_base import PageBase
from selenium.webdriver.common.by import By
from time import sleep
class PageShoppingCar(PageBase):
    '''购物车界面'''
    shop_community_locator = (503,1229)#定位好物社按钮
    shoppingcar_button_locator = (682,65)#定位购物车按钮
    goods_button_locator = (520,1100)#定位商品
    add_shopping_button_locator = (348,1235)#定位添加购物车按钮
    settleaccounts_button_locator = ('new UiSelector().textStartsWith("结算")')#定位结算按钮

    def ele_shop_community(self):
        '''点击好物社按钮'''
        self.driver.tap([(self.shop_community_locator)],500)
    def ele_shoppingcar(self):
        '''点击购物车按钮'''
        self.driver.tap([(self.shoppingcar_button_locator)],500)
    def ele_goods_button(self):
        '''点击要添加的物品'''
        self.driver.tap([(self.goods_button_locator)])

    def ele_add_shopping_button(self):
        '''点击添加购物车按钮'''
        self.driver.tap([(self.add_shopping_button_locator)])

    def ele_settleaccounts_button(self):
        '''点击结算按钮'''
        self.driver.find_element_by_android_uiautomator(self.settleaccounts_button_locator).click()


    def add_shoppingcar(self):
        '''添加购物车功能'''
        self.ele_shop_community()
        sleep(2)
        self.ele_shoppingcar()
        sleep(2)
        self.driver.swipe(345,900,345,300)
        sleep(2)
        self.ele_goods_button()
        sleep(4)
        self.ele_add_shopping_button()
        sleep(4)